package com.jierui.meter.frontend.base.domain;

import java.util.Objects;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class Header {

	private String did;

	private String version;

	private String screen;

	private String networkType;

	private String language;

	private String device;

	private String os;

	private String osVersion;

	private String location;

	private String ip;

	private String channel;

	private String manufacturer;


	public OsEnum getOsEnum() {
		return OsEnum.get(this.os);
	}

	public ManufacturerEnum getManufacturerEnum() {
		return ManufacturerEnum.get(this.manufacturer);
	}

	public enum ManufacturerEnum {
		XIAOMI(2, "Xiaomi"), HUAWEI(3, "HUAWEI");
		@Getter
		private String name;
		@Getter
		private Integer code;

		ManufacturerEnum(Integer code, String name) {
			this.code = code;
			this.name = name;
		}

		public static ManufacturerEnum get(String name) {
			if (name != null) {
				ManufacturerEnum[] values = values();
				for (ManufacturerEnum value : values) {
					if (value.name().equalsIgnoreCase(name)) {
						return value;
					}
				}
			}
			return null;
		}
	}

	public enum OsEnum {
		IOS(1), Android(2), M(3), PC(4);

		@Getter
		private Integer os;

		OsEnum(Integer os) {
			this.os = os;
		}

		public static OsEnum get(String name) {
			OsEnum[] values = values();
			for (OsEnum value : values) {
				if (value.name().equalsIgnoreCase(name)) {
					return value;
				}
			}
			return null;
		}

	}
	
	public enum PushPlatType {
		JIGUANG(1),
		XIAOMI(2),
		HUAWEI(3),
		;
		@Getter
		private Integer plat;

		PushPlatType(Integer plat) {
			this.plat = plat;
		}
		
		public static PushPlatType get(Integer platType) {

			if (Objects.isNull(platType)) {
				return null;
			}
			PushPlatType[] enums = values();
			for (PushPlatType anEnum : enums) {
				if (Objects.equals(anEnum.plat, platType)) {
					return anEnum;
				}
			}
			return null;
		}
	}
	
	@Getter
	public enum PushTagEnum {

	    not_notify,
	    notify,
	    notify_debug;

	    public static PushTagEnum get(String value){
	        PushTagEnum[] values = PushTagEnum.values();
	        for (PushTagEnum v : values) {
	            if(v.name().equals(value)){
	                return v;
	            }
	        }
	        return null;
	    }

	}
}
